package cn.josh.text;

import java.sql.ResultSet;
import java.sql.SQLException;

import cn.josh.bean.Ec_user;
import cn.josh.utill.JDBCUtil;

public class MysqlText
{
	public static void main(String[] args)
	{
		/*String sql = "insert into ec_user(LOGIN_NAME,PASSWORD,NAME,SEX,EMAIL,PHONE,ADDRESS,ROLE)\r\n"
						+	"values(?,?,?,?,?,?,?,?);";
		
		String[] info = {"3336@qq.com","123","hh","1","333@qq.com","15918738035","nnnnn","0"};
		
		JDBCUtil.executeUpdate(sql, info);*/
		
		String sql = "select * from ec_user where login_name = ?;";
		String[] info = {"3336@qq.com"};
		
		ResultSet rs = JDBCUtil.executeQuery(sql, info);
		
		try 
		{
			if(rs.next())
			{
				Ec_user user_db = new Ec_user();
				
				String userName = rs.getString("login_name");
				String password = rs.getString("password");
				String name = rs.getString("name");
				
				user_db.setLogin_name(userName);
				user_db.setPassword(password);
				user_db.setName(name);
				
				System.out.println("查询到用户");
				
			}
		}
		catch (SQLException e) 
		{
			System.out.println("没有查询到用户");
			e.printStackTrace();
		}
	}
}
